class Solution {
public:
    string longestCommonPrefix(vector<string> &strs) {
        // Start typing your C/C++ solution below
        // DO NOT write int main() function
        string result;
    	if (strs.size() == 0) {
			return result;
		} else if (strs.size() == 1) {
			return strs[0];
		}

		for (int i = 0; i < strs[0].length(); ++i) {
			char ch = strs[0][i];
			for (int j = 0; j < strs.size(); ++j) {
    			if (strs[j].length() <= i || strs[j][i] != ch) {
					return result;
				}
			}
			result += ch;
		}
		return result;
	}
};